﻿@model System.Collections.Generic.List<MyCompanyName.AbpZeroTemplate.Web.Areas.Okr.Models.StatisticsModel>
@{
    ViewBag.Title = "Statistics";
}

<div class="portlet">
    <div class="portlet-title">
        <div class="caption">
            <i class="fa fa-bell-o"></i>统计
        </div>
    </div>
    <div class="portlet-body">
        <form method="post" action="/Okr/Daybook/Statistics?dt=@DateTime.Now.Ticks">
            <div class="pull-right">
                <div id="sample_1_filter" class="dataTables_filter">
                    <label>
                        客户名:
                        <input type="search" id="txt_CName" name="CustomerName" value="@ViewBag.CName" required class="form-control input-small input-inline" placeholder="" aria-controls="sample_1">
                        项目名:
                        <input type="search" id="txt_PName" name="ProjectName" required value="@ViewBag.PName" class="form-control input-small input-inline" placeholder="" aria-controls="sample_1">
                        <input type="submit" value="查询" style="width:50px" class="btn blue" />
                        <input type="button" onclick="dayExport()" value="导出" style="width:50px" class="btn blue" />
                    </label>
                </div>
            </div>
        </form>

        <div class="table-scrollable">
            <table class="table table-striped table-bordered table-advance">
                <thead>
                    <tr>
                        <th>
                            客户
                        </th>
                        <th>
                            项目
                        </th>
                        <th>
                            人员
                        </th>
                        <th>
                            工时
                        </th>
                        <th>
                            占比
                        </th>
                        <th>
                            开始时间
                        </th>
                        <th>
                            结束时间
                        </th>
                        <th>
                            操作
                        </th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {
                        <tr>
                            <td>@item.Customer</td>
                            <td>@item.Project</td>
                            <td>@item.Name</td>
                            <td>@item.Hours</td>
                            <td>@item.Proportion</td>
                            <td>@item.StartTime</td>
                            <td>@item.EndTime</td>
                            <td><a href="#" onclick="downDetail(@item.UserId)">下载明细</a></td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</div>

<script type="text/javascript">
    var dayExport = function () {
        var txt_CName = document.getElementById("txt_CName").value;
        var txt_PName = document.getElementById("txt_PName").value;
        $.ajax({
            url: "/Okr/Daybook/Export",
            context: document.body,
            data: { CustomerName: txt_CName, ProjectName: txt_PName },
            success: function (response) {
                app.downloadTempFile(response.result);
            }
        });
    }

    var downDetail=function(userId)
    {
        var txt_CName = document.getElementById("txt_CName").value;
        var txt_PName = document.getElementById("txt_PName").value;
        $.ajax({
            url: "/api/services/app/daybook/GetDaybookStatisticsDetail",
            context: document.body,
            data: { UserId:userId,CustomerName: txt_CName, ProjectName: txt_PName },
            success: function (response)
            {
                app.downloadTempFile(response.result);
            }
        });
    }

</script>